import moment from 'moment';
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
const DATE_FORMAT = 'YYYY-MM-DD';

export function formatToDateTime(
    date: moment.MomentInput = null,
    format = DATE_TIME_FORMAT
): string {
    return moment(date).format(format);
}

export function formatToStartTime(
    date: moment.MomentInput = new Date(),
    format = DATE_FORMAT
): string {
    return `${moment(date).format(format)}00:00:00`;
}

export function formatToEndTime(
    date: moment.MomentInput = new Date(),
    format = DATE_FORMAT
): string {
    return `${moment(date).format(format)}23:59:59`;
}

export function dateSubtract(date: moment.MomentInput = null, type: any = 'days', days = 1, format = DATE_TIME_FORMAT): string {
    return `${formatToDate(moment(date).subtract(days, type), format)}`
}

export function dateAdd(date: moment.MomentInput = null, type: any = 'days', days = 1, format = DATE_TIME_FORMAT): string {
    return `${moment(date).add(days, type).format(format)}`
}

export function formatToDate(date: moment.MomentInput = null, format = DATE_FORMAT): string {
    return moment(date).format(format);
}
export function formatDayTime(
    date: moment.MomentInput = new Date(),
    format = DATE_FORMAT
): string {
    return `${moment(date).format(format)}`;
}